package com.smf.lsc.authorization.security.util;

import java.io.Serializable;

/**
 * 统一返回对象
 * Created on 2021/11/19.
 *
 * @author ln
 * @since 1.0
 */
public class Result<T> implements Serializable {
 
    /**
     * 返回编码
     */
    private Integer code = 0;
 
    /**
     * 返回信息
     */
    private String message = "";
 
    /**
     * 返回数据
     */
    private T data;
 
    /**
     * 标识
     */
    private FlagValue flag;
    
    /**
     *  返回信息标识枚举值
     * @author ln
     *
     */
	public enum FlagValue{
		/**
		 * 成功
		 */
    	SUCCESS,
    	/**
    	 * 警告
    	 */
    	WARN,
    	/**
    	 * 失败
    	 */
    	ERROR
    }
    
    public Result() {
    }

    public int getCode() {
        return code;
    }
 
    public void setCode(Integer code) {
        this.code = code;
    }
 
    public String getMessage() {
        return this.message;
    }
 
    public void setMessage(String message) {
        this.message = message;
    }
 
    public T getData() {
        return data;
    }
 
    public void setData(T data) {
        this.data = data;
    }
 
    public FlagValue getFlag() {
		return flag;
	}

	public void setFlag(FlagValue flag) {
		this.flag = flag;
	}
    
    
    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public Result(Integer code, String msg, T data) {
    	this.setMessage(msg);
        this.setData(data);
        this.setCode(code);
    }
    
    public Result(Integer code, String msg, T data, FlagValue flag) {
    	this.setMessage(msg);
        this.setData(data);
        this.setCode(code);
        this.setFlag(flag);
    }
    
    
}